package com.sys.gradepaysys.controller.stuServlet;

import com.alibaba.fastjson.JSON;
import com.sys.gradepaysys.entity.Clazz;
import com.sys.gradepaysys.entity.Grade;
import com.sys.gradepaysys.entity.ResultData;
import com.sys.gradepaysys.service.StudentService;
import com.sys.gradepaysys.service.StudentServiceImpl;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import java.io.IOException;
import java.util.List;

@WebServlet(name = "getAllGradeServlet", value = "/getAllGradeServlet")
public class getAllGradeServlet extends HttpServlet {
    private StudentService studentService = new StudentServiceImpl();

    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        List<Grade> allGrade = studentService.getAllGrade();
        String s = "";
        s = JSON.toJSONString(new ResultData<>(200, "登陆成功!", allGrade));
        response.setContentType("text/json;charset=utf-8");
        response.getWriter().write(s);
    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doGet(request, response);
    }
}
